using MicroMsg.Common.Event;
using MicroMsg.Common.Utils;
using MicroMsg.Protocol;
using MicroMsg.Resource.@string;
using MicroMsg.Scene;
using MicroMsg.UI.UserContrl;
using MicroMsg.UI.Util;
using Microsoft.Phone.Shell;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
namespace MicroMsg.UI.Page
{
	public class RegByPhoneStepInputNum : BasePage
	{
		private const string TAG = "RegByPhoneStepInputNum";
		private EventWatcher mWatcherPhoneReg;
		public static string sStrNameToLogin;
		internal Grid LayoutRoot;
		internal Grid sencondRoot;
		internal panelTitle2Line panelTitle;
		internal StackPanel ContentPanel;
		internal InputPhoneNumCtrl mPhoneNumInputer;
		internal TextBlock textBlock1;
		internal SeePrivacyCtrl seePrivacyCtrl;
		private bool _contentLoaded;
		public RegByPhoneStepInputNum()
		{
			this.InitializeComponent();
			this.SetAppBarWording();
		}
		protected override void OnPageIn(object[] object_0)
		{
			if (this.mWatcherPhoneReg == null)
			{
				this.mWatcherPhoneReg = new EventWatcher(this, null, new EventHandlerDelegate(this.onPhoneAuthRegHandler));
				EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_MOBILEREG_SETPHONE_SUCCESS, this.mWatcherPhoneReg);
				EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_MOBILEREG_SETPHONE_ERR, this.mWatcherPhoneReg);
			}
		}
		protected override void OnPageOut()
		{
			if (this.mWatcherPhoneReg != null)
			{
				EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_MOBILEREG_SETPHONE_SUCCESS, this.mWatcherPhoneReg);
				EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_MOBILEREG_SETPHONE_ERR, this.mWatcherPhoneReg);
				this.mWatcherPhoneReg = null;
			}
		}
		private void onPhoneAuthRegHandler(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			if (evtArgs == null)
			{
				return;
			}
			this.enableAllControls();
			if (evtArgs.mEventID == EventConst.ON_NETSCENE_MOBILEREG_SETPHONE_SUCCESS)
			{
				base.GoToPage("/Source/UI/LoginViews/RegByPhoneStepInputVCode.xaml", new object[]
				{
					RegByPhoneStepInputNum.sStrNameToLogin,
					this.mPhoneNumInputer.txtCountry.get_Text()
				}, false);
				return;
			}
			if (evtArgs.mEventID == EventConst.ON_NETSCENE_MOBILEREG_SETPHONE_ERR)
			{
				RetConst retConst = RetConst.MM_OK;
				if (evtArgs.mObject != null)
				{
					retConst = (RetConst)evtArgs.mObject;
					Log.smethod_5("RegByPhoneStepInputNum", "onMobileResetPwdHandler:evtArgs.mObject is" + retConst);
				}
				else
				{
					Log.smethod_5("RegByPhoneStepInputNum", "onMobileResetPwdHandler:evtArgs.mObject is null");
				}
				RetConst retConst2 = retConst;
				if (retConst2 > RetConst.MM_ERR_MOBILE_NEEDADJUST)
				{
					switch (retConst2)
					{
					case RetConst.MM_ERR_USER_BIND_MOBILE:
						break;
					case RetConst.MM_ERR_USER_MOBILE_UNMATCH:
						goto IL_124;
					case RetConst.MM_ERR_MOBILE_FORMAT:
						MMMessageBox.Show(strings.PCon_Bind_Msg_BindPhone_FormatTip, true, "确定");
						return;
					default:
						switch (retConst2)
						{
						case RetConst.MM_ERR_MOBILE_BINDED:
							break;
						case RetConst.MM_ERR_FREQ_LIMITED:
							MMMessageBox.Show(strings.Reg_PhoneNum_MsgTooFreq, true, "确定");
							return;
						default:
							goto IL_124;
						}
						break;
					}
					LoginMainView.sStrNameToLogin = this.mPhoneNumInputer.GetPhoneNumber();
					base.GoToPage("/Source/UI/LoginViews/LogByPhonePassword.xaml", null, false);
					return;
				}
				if (retConst2 == RetConst.MM_ERR_CLIENT)
				{
					MMMessageBox.Show(strings.Reg_PhoneNum_MsgBadNet, true, "确定");
					return;
				}
				if (retConst2 == RetConst.MM_ERR_MOBILE_NEEDADJUST)
				{
					MMMessageBox.Show(strings.PCon_Bind_Msg_BindPhone_NeedAdjust, true, "确定");
					return;
				}
				IL_124:
				MMMessageBox.Show(strings.Reg_PhoneNum_MsgBadNum, true, "确定");
			}
		}
		private void btnPreviousStep_Click(object sender, EventArgs e)
		{
			base.GoBack();
		}
		private void btnNextStep_Click(object sender, EventArgs e)
		{
			this.disableAllControls();
			base.Focus();
			string phoneNumber = this.mPhoneNumInputer.GetPhoneNumber();
			ServiceCenter.sceneBindOpMobileForReg.doScene(phoneNumber);
			RegByPhoneStepInputNum.sStrNameToLogin = phoneNumber;
		}
		public void inputDone(object sender, object object_0)
		{
			(base.get_ApplicationBar().get_Buttons().get_Item(0) as ApplicationBarIconButton).set_IsEnabled(true);
		}
		public void inputNotDone(object sender, object object_0)
		{
			(base.get_ApplicationBar().get_Buttons().get_Item(0) as ApplicationBarIconButton).set_IsEnabled(false);
		}
		private void seePrivacyCtrl_mEventCBoxChanged(object sender, RoutedEventArgs e)
		{
			if (sender != null && sender is CheckBox)
			{
				CheckBox checkBox = sender as CheckBox;
				bool? isChecked = checkBox.get_IsChecked();
				if (!isChecked.GetValueOrDefault() && isChecked.get_HasValue())
				{
					(base.get_ApplicationBar().get_Buttons().get_Item(0) as ApplicationBarIconButton).set_IsEnabled(false);
					return;
				}
				if (this.mPhoneNumInputer.mBIsInputDone)
				{
					(base.get_ApplicationBar().get_Buttons().get_Item(0) as ApplicationBarIconButton).set_IsEnabled(true);
				}
			}
		}
		private void enableAllControls()
		{
			ProcessingCover.releaseProgressBar(this.LayoutRoot);
			(base.get_ApplicationBar().get_Buttons().get_Item(0) as ApplicationBarIconButton).set_IsEnabled(true);
		}
		private void disableAllControls()
		{
			ProcessingCover.getProgressBar(this.LayoutRoot, null, null, false, false, null);
			(base.get_ApplicationBar().get_Buttons().get_Item(0) as ApplicationBarIconButton).set_IsEnabled(false);
		}
		public void SetAppBarWording()
		{
			if (base.get_ApplicationBar() != null && 1 == base.get_ApplicationBar().get_Buttons().get_Count())
			{
				ApplicationBarIconButton applicationBarIconButton = (ApplicationBarIconButton)base.get_ApplicationBar().get_Buttons().get_Item(0);
				applicationBarIconButton.set_Text(strings.COM_Next);
			}
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/LoginViews/RegByPhoneStepInputNum.xaml", 2));
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.sencondRoot = (Grid)base.FindName("sencondRoot");
			this.panelTitle = (panelTitle2Line)base.FindName("panelTitle");
			this.ContentPanel = (StackPanel)base.FindName("ContentPanel");
			this.mPhoneNumInputer = (InputPhoneNumCtrl)base.FindName("mPhoneNumInputer");
			this.textBlock1 = (TextBlock)base.FindName("textBlock1");
			this.seePrivacyCtrl = (SeePrivacyCtrl)base.FindName("seePrivacyCtrl");
		}
	}
}
